package cn.kgc.javaweb.servlet;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * @author: mosin
 * @version: v1.0  2022/10/25
 * 请求方式对重写方法的影响
 *
 *   MethodServlet  methodServlet   =   new MethodServlet()
 *   get   ->  doGet
 *   post  ->  doPost
 *
 *   重写 service    -> service
 *
 *
 */
@WebServlet("/method")
public class MethodServlet extends HttpServlet {


    //处理get请求
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("doGet()");
    }

    //处理post请求
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("doPost()");
    }

    //  get  post delete  put 等请求方式  推荐
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        System.out.println("service");
    }


}
